package com.cms.sync.service;

import java.util.List;

import com.cms.sync.model.SyncLogs;
import com.service.AbstractDateService;
import com.utils.dbcp.ConnectionManager;
import com.utils.dbcp.ModelGenerator;

public class SyncLogsServiceImpl extends AbstractDateService implements SyncLogsService {

	@Override
	public List<SyncLogs> getAllBySource(String source) {
		String sql = "select * from t_synclogs where source='"+source+"'";
		logger.info("[SQL] [method:getAllByTypename] ["+sql+"]");
		ModelGenerator<SyncLogs> model = new ModelGenerator<SyncLogs>(SyncLogs.class);
		return model.generateList(base,sql.toString());
	}

	@Override
	public boolean save(SyncLogs t) {
		String sql = "insert into t_synclogs(appid,uid,cporderid,orderid,orderstatus,payfee,productcode,productname,paytime,source,remark,createtime) values (" +
				"'" +t.getAppid()+"',"+
				"'" +t.getUid()+"',"+
				"'" +t.getCporderid()+"',"+
				"'" +t.getOrderid()+"',"+
				"'" +t.getOrderstatus()+"',"+
				t.getPayfee()+","+
				"'" +t.getProductcode()+"',"+
				"'" +t.getProductname()+"',"+
				"'" +t.getPaytime()+"',"+
				"'" +t.getSource()+"',"+
				"'" +t.getRemark()+"',"+
				"'" +t.getCreatetime()+"'"+
				")";
		logger.info("[SQL] [method:save] ["+sql+"]");
		return ConnectionManager.getInstance().execute(base,sql);
	}

	@Override
	public List<SyncLogs> idRepeatOrder(String orderId, String source) {
		String sql = "select * from t_synclogs where orderid='"+orderId+"' and source='"+source+"'";
		logger.info("[SQL] [method:idRepeatOrder] ["+sql+"]");
		ModelGenerator<SyncLogs> model = new ModelGenerator<SyncLogs>(SyncLogs.class);
		return model.generateList(base,sql.toString());
	}

}
